import { http } from '@/utils/request.js'

// 获取营业额统计
export function getShopStatistics() {
	return http.request({
		url: '/shops/orders/statistics',
		method: 'GET'
	})
}

// 获取订单列表
export function getShopOrders(params) {
	return http.request({
		url: '/shops/orders',
		method: 'GET',
		params
	})
}

// 获取订单详情
export function getShopOrderDetail(orderId) {
	return http.request({
		url: `/shops/orders/${orderId}`,
		method: 'GET'
	})
}

// 确认发货
export function confirmShip(orderId, data) {
	return http.request({
		url: `/shops/orders/${orderId}/ship`,
		method: 'POST',
		data
	})
}

// 确认完成订单
export function confirmComplete(orderId) {
	return http.request({
		url: `/shops/orders/${orderId}/complete`,
		method: 'POST'
	})
}

// 获取未读订单数量
export function getUnreadOrderCount() {
	return http.request({
		url: '/shops/orders/unread/count',
		method: 'GET'
	})
}

// 标记订单为已读
export function markOrderAsRead(orderId) {
	return http.request({
		url: `/shops/orders/${orderId}/read`,
		method: 'POST'
	})
}

// 获取商家数据分析
export function getShopAnalytics(period) {
	return http.request({
		url: '/shops/analytics',
		method: 'GET',
		params: { period }
	})
}

// 获取商品列表
export function getShopProducts(params) {
	return http.request({
		url: '/shops/products',
		method: 'GET',
		params
	})
}

// 添加商品
export function addShopProduct(data) {
	return http.request({
		url: '/shops/products',
		method: 'POST',
		data
	})
}

// 更新商品
export function updateShopProduct(productId, data) {
	return http.request({
		url: `/shops/products/${productId}`,
		method: 'PUT',
		data
	})
}

// 删除商品
export function deleteShopProduct(productId) {
	return http.request({
		url: `/shops/products/${productId}`,
		method: 'DELETE'
	})
}

// 切换商品状态
export function toggleProductStatus(productId, status) {
	return http.request({
		url: `/shops/products/${productId}/status`,
		method: 'PUT',
		data: { status }
	})
}

// 获取店铺设置
export function getShopSettings() {
	return http.request({
		url: '/shops/settings',
		method: 'GET'
	})
}

// 更新店铺设置
export function updateShopSettings(data) {
	return http.request({
		url: '/shops/settings',
		method: 'PUT',
		data
	})
}

// 取消订单
export function cancelShopOrder(orderId, reason) {
	return http.request({
		url: `/shops/orders/${orderId}/cancel`,
		method: 'POST',
		data: { reason }
	})
} 